From: Stefan Monnier Date: Thu, 15 Mar 2012 01:38:40 +0000 (-0400) Subject: * lisp/imenu.el: Fix multiple inheritance breakage. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~2326^2~2761^2~24 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=103af3fe878c2816096389b3f34864e0e8636d81;p=emacs.git * lisp/imenu.el: Fix multiple inheritance breakage. (imenu-add-to-menubar): Don't add a redundant index. (imenu-update-menubar): Handle a dynamically composed keymap. Fixes: debbugs:9199 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 14531f6adc5..083d58b8e8f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-03-15 Stefan Monnier + + * imenu.el: Fix multiple inheritance breakage (bug#9199). + (imenu-add-to-menubar): Don't add a redundant index. + (imenu-update-menubar): Handle a dynamically composed keymap. + 2012-03-13 Katsumi Yamaoka * mail/sendmail.el (mail-encode-header): diff --git a/lisp/imenu.el b/lisp/imenu.el index 9a847f32e89..8363956355b 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -963,13 +963,14 @@ See the command `imenu' for more information." imenu-generic-expression (not (eq imenu-create-index-function 'imenu-default-create-index-function))) - (let ((newmap (make-sparse-keymap))) - (set-keymap-parent newmap (current-local-map)) - (setq imenu--last-menubar-index-alist nil) - (define-key newmap [menu-bar index] - `(menu-item ,name ,(make-sparse-keymap "Imenu"))) - (use-local-map newmap) - (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) + (unless (keymapp (lookup-key (current-local-map) [menu-bar index])) + (let ((newmap (make-sparse-keymap))) + (set-keymap-parent newmap (current-local-map)) + (setq imenu--last-menubar-index-alist nil) + (define-key newmap [menu-bar index] + `(menu-item ,name ,(make-sparse-keymap "Imenu"))) + (use-local-map newmap) + (add-hook 'menu-bar-update-hook 'imenu-update-menubar))) (error "The mode `%s' does not support Imenu" (format-mode-line mode-name)))) @@ -1008,6 +1009,9 @@ to `imenu-update-menubar'.") (car (cdr menu)))) 'imenu--menubar-select)) (setq old (lookup-key (current-local-map) [menu-bar index])) + ;; This should never happen, but in some odd cases, potentially, + ;; lookup-key may return a dynamically composed keymap. + (if (keymapp (cadr old)) (setq old (cadr old))) (setcdr old (cdr menu1))))))) (defun imenu--menubar-select (item)